/**
 * 身份证信息脱敏
 * @param idCard 身份证
 * @param headLength 前几位的显示数量
 * @param tailLength 后几位的显示数量
 * @returns
 */
export const hideIDCardInfo = (
    idCard: string | undefined | null,
    headLength = 6,
    tailLength = 1,
) => {
    if (!Boolean(idCard?.trim())) return ''

    const ID_CARD_LENGTH = 18

    const substringLength = ID_CARD_LENGTH - tailLength

    const symbols = Array(ID_CARD_LENGTH - headLength - tailLength)
        .fill('*')
        .join('')

    return `${idCard!.substring(0, headLength)}${symbols}${idCard!.substring(substringLength)}`
}

/** 手机号脱敏 */
export const hidePhoneInfo = (v: string | undefined | null) => {
    if (!Boolean(v?.trim())) return ''

    return `${v!.substring(0, 3)}****${v!.substring(7)}`
}
